#include "entity.h"
int Entity::currentId = 0;

Entity::Entity(int initX, int initY, bool ifmovable, bool ifbase): Object()
{
    id = ++currentId;
    x = targX = initX;
    y = targY = initY;
    movable = ifmovable;
    base = ifbase;

    health = 1000;
    alive = true;
    dir = "N";
}
Entity::Entity() {
    id = ++currentId;
}

void Entity::update(){
    if(health <= 0){
        alive = false;
    }
    if(movable != false && (x != targX || y != targY)){
        if(targX > x){
           x++;
        } else if(targX < x){
            x--;
        }
        if(targY > y){
            y++;
        } else if(targY < y){
            y--;
        }
        if(targX > x + 100){
            dir = "E";
        } else if(targX < x - 100){
            dir = "W";
        } else if(targY > y + 100){
            dir = "S";
        } else if(targY < y - 100){
            dir = "N";
        }
    }
}

void Entity::saveState(){

}
void Entity::load(){

}

